
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.PreventionType;
import cn.edu.scau.cmi.hombio.domain.TaskPrevention;
import cn.edu.scau.cmi.hombio.domain.Unit;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class PreventionTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected PreventionTypeService service;

	/**
	 * Instantiates a new PreventionTypeServiceTest.
	 *
	 */
	public PreventionTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing PreventionType entity
	* 
	 */
	@Test
	public void deletePreventionType() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionType 
		PreventionType preventiontype = new cn.edu.scau.cmi.hombio.domain.PreventionType();
		service.deletePreventionType(preventiontype);
	}

	/**
	 * Operation Unit Test
	* Return a count of all PreventionType entity
	* 
	 */
	@Test
	public void countPreventionTypes() {
		Integer response = null;
		response = service.countPreventionTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countPreventionTypes
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void savePreventionTypeMedicineByMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionTypeMedicineByMedicineId 
		Integer id = 0;
		Medicine related_medicinebymedicineid = new cn.edu.scau.cmi.hombio.domain.Medicine();
		PreventionType response = null;
		response = service.savePreventionTypeMedicineByMedicineId(id, related_medicinebymedicineid);
		// TODO: JUnit - Add assertions to test outputs of operation: savePreventionTypeMedicineByMedicineId
	}

	/**
	 * Operation Unit Test
	* Load an existing PreventionType entity
	* 
	 */
	@Test
	public void loadPreventionTypes() {
		Set<PreventionType> response = null;
		response = service.loadPreventionTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadPreventionTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deletePreventionTypeMedicineByReportMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionTypeMedicineByReportMedicineId 
		Integer preventiontype_id = 0;
		Integer related_medicinebyreportmedicineid_id = 0;
		PreventionType response = null;
		response = service.deletePreventionTypeMedicineByReportMedicineId(preventiontype_id, related_medicinebyreportmedicineid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePreventionTypeMedicineByReportMedicineId
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findPreventionTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findPreventionTypeByPrimaryKey 
		Integer id_1 = 0;
		PreventionType response = null;
		response = service.findPreventionTypeByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findPreventionTypeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskPrevention entity
	* 
	 */
	@Test
	public void deletePreventionTypeTaskPreventions() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionTypeTaskPreventions 
		Integer preventiontype_id_1 = 0;
		Integer related_taskpreventions_id = 0;
		PreventionType response = null;
		response = service.deletePreventionTypeTaskPreventions(preventiontype_id_1, related_taskpreventions_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePreventionTypeTaskPreventions
	}

	/**
	 * Operation Unit Test
	* Save an existing PreventionType entity
	* 
	 */
	@Test
	public void savePreventionType() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionType 
		PreventionType preventiontype_1 = new cn.edu.scau.cmi.hombio.domain.PreventionType();
		service.savePreventionType(preventiontype_1);
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void savePreventionTypeMedicineByReportMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionTypeMedicineByReportMedicineId 
		Integer id_2 = 0;
		Medicine related_medicinebyreportmedicineid = new cn.edu.scau.cmi.hombio.domain.Medicine();
		PreventionType response = null;
		response = service.savePreventionTypeMedicineByReportMedicineId(id_2, related_medicinebyreportmedicineid);
		// TODO: JUnit - Add assertions to test outputs of operation: savePreventionTypeMedicineByReportMedicineId
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deletePreventionTypeMedicineByMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionTypeMedicineByMedicineId 
		Integer preventiontype_id_2 = 0;
		Integer related_medicinebymedicineid_id = 0;
		PreventionType response = null;
		response = service.deletePreventionTypeMedicineByMedicineId(preventiontype_id_2, related_medicinebymedicineid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePreventionTypeMedicineByMedicineId
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskPrevention entity
	* 
	 */
	@Test
	public void savePreventionTypeTaskPreventions() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionTypeTaskPreventions 
		Integer id_3 = 0;
		TaskPrevention related_taskpreventions = new cn.edu.scau.cmi.hombio.domain.TaskPrevention();
		PreventionType response = null;
		response = service.savePreventionTypeTaskPreventions(id_3, related_taskpreventions);
		// TODO: JUnit - Add assertions to test outputs of operation: savePreventionTypeTaskPreventions
	}

	/**
	 * Operation Unit Test
	* Save an existing Unit entity
	* 
	 */
	@Test
	public void savePreventionTypeUnitByReportUnitId() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionTypeUnitByReportUnitId 
		Integer id_4 = 0;
		Unit related_unitbyreportunitid = new cn.edu.scau.cmi.hombio.domain.Unit();
		PreventionType response = null;
		response = service.savePreventionTypeUnitByReportUnitId(id_4, related_unitbyreportunitid);
		// TODO: JUnit - Add assertions to test outputs of operation: savePreventionTypeUnitByReportUnitId
	}

	/**
	 * Operation Unit Test
	* Save an existing Unit entity
	* 
	 */
	@Test
	public void savePreventionTypeUnitByUnitId() {
		// TODO: JUnit - Populate test inputs for operation: savePreventionTypeUnitByUnitId 
		Integer id_5 = 0;
		Unit related_unitbyunitid = new cn.edu.scau.cmi.hombio.domain.Unit();
		PreventionType response = null;
		response = service.savePreventionTypeUnitByUnitId(id_5, related_unitbyunitid);
		// TODO: JUnit - Add assertions to test outputs of operation: savePreventionTypeUnitByUnitId
	}

	/**
	 * Operation Unit Test
	* Delete an existing Unit entity
	* 
	 */
	@Test
	public void deletePreventionTypeUnitByUnitId() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionTypeUnitByUnitId 
		Integer preventiontype_id_3 = 0;
		Integer related_unitbyunitid_id = 0;
		PreventionType response = null;
		response = service.deletePreventionTypeUnitByUnitId(preventiontype_id_3, related_unitbyunitid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePreventionTypeUnitByUnitId
	}

	/**
	 * Operation Unit Test
	* Return all PreventionType entity
	* 
	 */
	@Test
	public void findAllPreventionTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllPreventionTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<PreventionType> response = null;
		response = service.findAllPreventionTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllPreventionTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Unit entity
	* 
	 */
	@Test
	public void deletePreventionTypeUnitByReportUnitId() {
		// TODO: JUnit - Populate test inputs for operation: deletePreventionTypeUnitByReportUnitId 
		Integer preventiontype_id_4 = 0;
		Integer related_unitbyreportunitid_id = 0;
		PreventionType response = null;
		response = service.deletePreventionTypeUnitByReportUnitId(preventiontype_id_4, related_unitbyreportunitid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePreventionTypeUnitByReportUnitId
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
